/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.mycompany.entidades;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.hibernate.search.annotations.Analyze;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Index;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.Store;

/**
 *
 * @author Johnny
 */
@Entity
@Indexed
@Table(catalog = "celulares", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Articulo.findAll", query = "SELECT a FROM Articulo a"),
    @NamedQuery(name = "Articulo.findByCodigo", query = "SELECT a FROM Articulo a WHERE a.codigo = :codigo"),
    @NamedQuery(name = "Articulo.findByDescripcion", query = "SELECT a FROM Articulo a WHERE a.descripcion = :descripcion"),
    @NamedQuery(name = "Articulo.findByMarca", query = "SELECT a FROM Articulo a WHERE a.marca = :marca"),
    @NamedQuery(name = "Articulo.findByModelo", query = "SELECT a FROM Articulo a WHERE a.modelo = :modelo"),
    @NamedQuery(name = "Articulo.findByEstado", query = "SELECT a FROM Articulo a WHERE a.estado = :estado"),
    @NamedQuery(name = "Articulo.findByIva", query = "SELECT a FROM Articulo a WHERE a.iva = :iva"),
    @NamedQuery(name = "Articulo.findByPunitario", query = "SELECT a FROM Articulo a WHERE a.punitario = :punitario"),
    @NamedQuery(name = "Articulo.findByPventa", query = "SELECT a FROM Articulo a WHERE a.pventa = :pventa"),
    @NamedQuery(name = "Articulo.findBySminimo", query = "SELECT a FROM Articulo a WHERE a.sminimo = :sminimo"),
    @NamedQuery(name = "Articulo.findByStock", query = "SELECT a FROM Articulo a WHERE a.stock = :stock"),
    @NamedQuery(name = "Articulo.findByTipo", query = "SELECT a FROM Articulo a WHERE a.tipo = :tipo")})
public class Articulo
  implements Serializable
{
  private static final long serialVersionUID = 1L;

  @Id
  @GeneratedValue(strategy=GenerationType.IDENTITY)
  @Basic(optional=false)
  @Column(nullable=false)
  private Integer codigo;

  @Column(length=40, unique=true)
  @Field(index=Index.YES, analyze=Analyze.YES, store=Store.YES)
  private String codArticulo;

  @Column(length=85)
  @Field(index=Index.YES, analyze=Analyze.YES, store=Store.YES)
  private String descripcion;

  @Column(length=45)
  @Field(index=Index.YES, analyze=Analyze.YES, store=Store.YES)
  private String marca;

  @Column(length=45)
  @Field(index=Index.YES, analyze=Analyze.YES, store=Store.YES)
  private String modelo;
  private Integer estado;

  @Column(length=2)
  private String iva;

  @Column(precision=22)
  private Double punitario;

  @Column(precision=22)
  private Double pventa;
  private Integer sminimo;
  private Integer stock;
  private Integer tipo;

  @OneToMany(cascade={javax.persistence.CascadeType.ALL}, mappedBy="idArticulo")
  private List<Serie> serieList;

  @OneToMany(mappedBy="codigoArticulo")
  private List<Proveedorarticulo> proveedorArticuloList;

  public Articulo()
  {
  }

  public Articulo(Integer codigo)
  {
    this.codigo = codigo;
  }

  public Integer getCodigo() {
    return this.codigo;
  }

  public void setCodigo(Integer codigo) {
    this.codigo = codigo;
  }

  public String getCodArticulo() {
    return this.codArticulo;
  }

  public void setCodArticulo(String codArticulo) {
    this.codArticulo = codArticulo;
  }

  public String getDescripcion() {
    return this.descripcion;
  }

  public void setDescripcion(String descripcion) {
    this.descripcion = descripcion;
  }

  public String getMarca() {
    return this.marca;
  }

  public void setMarca(String marca) {
    this.marca = marca;
  }

  public String getModelo() {
    return this.modelo;
  }

  public void setModelo(String modelo) {
    this.modelo = modelo;
  }

  public Integer getEstado() {
    return this.estado;
  }

  public void setEstado(Integer estado) {
    this.estado = estado;
  }

  public String getIva() {
    return this.iva;
  }

  public void setIva(String iva) {
    this.iva = iva;
  }

  public Double getPunitario() {
    return this.punitario;
  }

  public void setPunitario(Double punitario) {
    this.punitario = punitario;
  }

  public Double getPventa() {
    return this.pventa;
  }

  public void setPventa(Double pventa) {
    this.pventa = pventa;
  }

  public Integer getSminimo() {
    return this.sminimo;
  }

  public void setSminimo(Integer sminimo) {
    this.sminimo = sminimo;
  }

  public Integer getStock() {
    return this.stock;
  }

  public void setStock(Integer stock) {
    this.stock = stock;
  }

  public Integer getTipo() {
    return this.tipo;
  }

  public void setTipo(Integer tipo) {
    this.tipo = tipo;
  }
  @XmlTransient
  @JsonIgnore
  public List<Serie> getSerieList() {
    return this.serieList;
  }

  public void setSerieList(List<Serie> serieList) {
    this.serieList = serieList;
  }
  @XmlTransient
  @JsonIgnore
  public List<Proveedorarticulo> getProveedorArticuloList() {
    return this.proveedorArticuloList;
  }

  public void setProveedorArticuloList(List<Proveedorarticulo> proveedorArticuloList) {
    this.proveedorArticuloList = proveedorArticuloList;
  }

  public int hashCode()
  {
    int hash = 0;
    hash += (this.codigo != null ? this.codigo.hashCode() : 0);
    return hash;
  }

  public boolean equals(Object object)
  {
    if (!(object instanceof Articulo)) {
      return false;
    }
    Articulo other = (Articulo)object;
    if (((this.codigo == null) && (other.codigo != null)) || ((this.codigo != null) && (!this.codigo.equals(other.codigo)))) {
      return false;
    }
    return true;
  }

  public String toString()
  {
    return "com.mycompany.entidades.Articulo[ codigo=" + this.codigo + " ]";
  }
}